﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HUBS1.HCMS.Entity;
using HUBS1.HCMS.Data;

namespace HUBS1.HCMS.SqlClient
{
    public class sql_hcity
    {
        string sqlstr = "";
        /// <summary>
        /// 返回所有列表
        /// </summary>
        /// <returns></returns>
        public List<H_City> getallcity(int provinceid)
        {
            if (provinceid == 0)
                sqlstr = "select * from H_City ";
            else
                sqlstr = "select * from H_City where provinceid="+provinceid.ToString();
            return ExecSql.GetTableList<H_City>(sqlstr);
        }

        /// <summary>
        /// 返回单条信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public H_City getitem(int id)
        {
            return new H_City(ExecSql.GetDataSet("select * from H_City where cityid="+id.ToString()+" ").Tables[0].Rows[0]);
        }

        /// <summary>
        /// 删除单条
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool delcity(int id)
        {
            if (ExecSql.SqlExecNoquery("delete from h_city where cityid=" + id.ToString() + "") > 0)
                return true;
            else
                return false;
        }

        /// <summary>
        /// 新增或者更新
        /// </summary>
        /// <param name="_city"></param>
        /// <returns></returns>
        public bool insertorupdate(H_City _city)
        {
            return ExecSql.InsertOrUpdateData<H_City>(_city);
        }
    }
}
